<template>
  <div style="padding:20px;height: 85%">
    <!--1.搜索框-->
    <el-form
      label-position=left
      label-width="80px"
      :model="queryData"
      inline="inline" >
      <el-row>
        <el-col :span="20">
          <el-form-item label="名称" style="width: 50%">
            <el-input v-model="queryData.name"></el-input>
          </el-form-item>
          <el-form-item label="名称">
            <el-input v-model="queryData.type"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item>
            <el-button type="primary" @click="initList">查询</el-button>
            <el-button @click="reset">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!---->
    <el-table
      :data="tableData"
      style="width: 100%;max-height: 85%;overflow: auto"
      :header-cell-style="{background:'#f0f0f0'}">
      <el-table-column  type="index" label="序号" width="50">
      </el-table-column>
      <el-table-column
        prop="date"
        label="日期"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
      <el-table-column label="操作" width="70">
        <template slot-scope="scope">
          <el-button type="text" @click.stop="updateItem(scope.row)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination style=" background-color: #ffffff;"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="queryData.pageNumber"
      :page-sizes="[10, 50, 100, 200]"
      :page-size="queryData.pageSize"
      layout=" total,sizes,->,jumper, prev, pager, next"
      :total="totalSize">
    </el-pagination>

    <el-dialog title="收货地址" :visible.sync="saveDialog">
      <el-form :model="item" ref="editForm">
        <el-form-item label="活动名称" :label-width="formLabelWidth">
          <el-input v-model="item.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="活动区域" :label-width="formLabelWidth">
          <el-select v-model="item.region" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeSaveDialog">取 消</el-button>
        <el-button type="primary" @click="saveItem">确 定</el-button>
      </div>
    </el-dialog>
  </div>

</template>

<script>
export default {
  name: 'optionThree',
  props: {},
  data() {
    return {
      queryData:{
        name: '',
        region: '',
        type: ''
      },
      tableData: [],
      totalSize:20,
      saveDialog: false,
      item: {
        name: '',
        region: '',
      },
      formLabelWidth: '120px'
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() { // 渲染后执行
    this.initList();
  },
  methods: {
    initList(){
      this.$api.dictionary.list(this.queryData).then(resp => {
        // this.tableData = resp.data;
        // this.totalSize=  resp.totalSize;

      })

    },
    reset(){
      this.queryData={};
      this.initList();
    },
    openSaveDialog(data){
      this.saveDialog=true;
      if(data){
        this.item=JSON.parse(JSON.stringify(data));
      }
    },
    closeSaveDialog(){
      this.saveDialog=false;
      this.item={};
    },
    saveItem(){
      this.$api.dictionary.update(this.item).then(resp => {
        this.saveDialog = false
        this. dictionaryList()
      })
    },
    updateItem(item){

    },
    deleteItem(){

    },
    handleSizeChange(){
      this.initList();
    },
    handleCurrentChange(){
      this.initList();
    },

  },

}
</script>

<style scoped>
.el-table::before {
  z-index: inherit;
}


</style>
